package com.xy.biz.mes.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.mes.domain.bo.ManufactureResultGoodsBO;
import com.xy.biz.mes.domain.po.ManufactureResultGoodsPO;
import com.xy.biz.mes.domain.query.ManufactureResultGoodsQuery;
import com.xy.biz.mes.domain.resp.GetManufactureResultGoodsResponse;
import com.xy.biz.mes.domain.req.SaveManufactureResultGoodsRequest;
import com.xy.biz.mes.domain.req.ListManufactureResultGoodsRequest;

/**
 *
 *
 * @author zgy
 * @date 2022-2-11
 */
public class ManufactureResultGoodsConverter {

	public static ManufactureResultGoodsPO toPO(ManufactureResultGoodsBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureResultGoodsPO(), true);
	}

	public static List<ManufactureResultGoodsPO> toPO(Collection<ManufactureResultGoodsBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureResultGoodsPO(), true);
	}

	public static ManufactureResultGoodsBO fromPO(ManufactureResultGoodsPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureResultGoodsBO());
	}

	public static List<ManufactureResultGoodsBO> fromPO(Collection<ManufactureResultGoodsPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureResultGoodsBO());
	}

	public static ManufactureResultGoodsBO toBO(SaveManufactureResultGoodsRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureResultGoodsBO(), true);
	}

	public static List<ManufactureResultGoodsBO> toBO(Collection<SaveManufactureResultGoodsRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureResultGoodsBO(), true);
	}

	public static GetManufactureResultGoodsResponse toResponse(ManufactureResultGoodsBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetManufactureResultGoodsResponse());
	}

	public static List<GetManufactureResultGoodsResponse> toResponse(Collection<ManufactureResultGoodsBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetManufactureResultGoodsResponse());
	}

	public static ManufactureResultGoodsQuery toQuery(ListManufactureResultGoodsRequest source) {
		if(null == source) {
			return null;
		}
		ManufactureResultGoodsQuery target = new ManufactureResultGoodsQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
